#ifndef SOCKET_ADDRESS_H
#define SOCKET_ADDRESS_H

#ifdef WIN32
#pragma comment(lib, "ws2_32.lib")
#include <winsock2.h>				
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#endif




class SocketAddress
{
private:

	struct sockaddr_in address;

public:

	SocketAddress(const char* ip = 0, unsigned short port = 0);
	SocketAddress(sockaddr_in addr);
	~SocketAddress();

	void					setIp(const char* ip_address);
	void					setPort(unsigned short port) { address.sin_port = htons(port); };
	
	struct sockaddr_in		getAddr()	{ return address; };
	char*					getIp()		{ return inet_ntoa(address.sin_addr); };
	unsigned short			getPort()	{ return ntohs(address.sin_port); };
};


#endif // SOCKET_ADDRESS_H